<div>
<table class="form_table"  style="width:600px;border:0px;/* margin:0 auto; */">
	<tr>
		<td colspan="2">
		<div style="float:left;width:270px;">
			系列表：<br/>
			<select multiple="multiple" size="28" id="mergeCollegeSelect" style="width:250px;">
				<option value="12">我爱我家</option>
				<option value="12">什么乱八澡</option>
				<option></option>
			</select>
		</div>
		
		<div style="float:left;width:60px;padding-top:200px;">
			<img id="collegeMoveOut" style="cursor:pointer;" src="statics/images/right_arrow.png"><br/>
			<img id="collegeMoveIn" style="cursor:pointer;" src="statics/images/left_arrow.png">
			<!-- <input type="button" id="collegeMoveOut" value=" &gt;&gt; " style="border:1px black solid;background:#f4f4f4;"><br/>
			<input type="button" id="collegeMoveIn" value=" &lt;&lt; " style="border:1px black solid;background:#f4f4f4;"> -->
		</div>
		
		<div style="float:left;width:200px;">
			需要合并的系：
			<select multiple="multiple" size="28" id="needToMergeCollege" style="width:250px;"></select>
		</div>
		</td>
	</tr>
	<tr>
		<td>合并后系名称：</td>
		<td><input type="text" id="newCollegeName" class="txtInput"></td>
	</tr>
	<tr><td></td><td><a href="javascript:void(0)" class="easyui-linkbutton" id="mergeButton" data-options="iconCls:'icon-ok'">合并</a></td></tr>
</table>

</div>

<script>
$(function(){

	loadMergeCollegeSelect();

	function loadMergeCollegeSelect() {
		$.ajax({
			url:'uni/colleges',
			success:function(result) {
				var options = $.map(result,function(row) {
					return '<option value="' + row.lqyxsm + '">' + row.lqyxsmc + '</option>';
				}).join('');
				$('#mergeCollegeSelect').html(options);
			}
		});
	}

	$('#collegeMoveOut').click(function(){
		$('#needToMergeCollege').append($('#mergeCollegeSelect :selected').remove());
	});

	$('#collegeMoveIn').click(function(){
		$('#mergeCollegeSelect').append($('#needToMergeCollege :selected').remove());
	});
	
	$('#mergeButton').click(function(){
		var lqyxsm = $.map($('#needToMergeCollege option'),function(row) {return row.value}).join(',');
		
		if(lqyxsm.indexOf(',') < 0) {$.messager.alert('提示','请至少选择两个学院！');return;}
		if(!$.trim($('#newCollegeName').val())) {$.messager.alert('提示','请输入合并后的学院名称！');return;}
		$.messager.confirm('提示','确认要合并学院么？警告：此操作不可逆转！',function(r){
			if(!r) return;
			$.messager.confirm('提示','再次警告：合并操作不可逆转，请务必确认！',function(r2) {
				if(r2) {
					$.ajax({
						url:'uni/mergeCollege',
						data:'oldIds=' + lqyxsm + "&newCollegeName=" + $('#newCollegeName').val(),
						success:function(result) {
							if(result.errorInfo != 'none') {
								$.messager.alert('提示',result.errorInfo);
								return;
							}

							$.messager.alert('提示','合并学院成功！');
							loadMergeCollegeSelect();
							$('#needToMergeCollege').html('');
						}
					});
				}
			});
		});
	});
});
</script>

